import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { NestFastifyApplication } from '@nestjs/platform-fastify'
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(new ValidationPipe());

  // 构建swagger文档
  const options = new DocumentBuilder()
    .setTitle('vue3-admin')
    .setDescription('nestjs 构建vue rbac权限系统后台api')
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('docs', app, document);

  if (process.env.NODE_ENV == 'development') {
    const { LoggingInterceptor } = await import('./common/interceptors/logging.interceptor');
    app.useGlobalInterceptors(new LoggingInterceptor());
  }
  
  app.setGlobalPrefix('api'); // 设置全局路由前缀

  await app.listen(3000);
}
bootstrap();
